package cn.com.code.hwjs;


import java.util.Scanner;

/**
 * @author zhengpei
 * @date 2022/4/26
 */
public class Hwjs33 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      String str = sc.nextLine();
      System.out.println(ipToLong(str));
      long l = Long.parseLong(sc.nextLine());
      System.out.println(longToIp(l));
    }
  }

  private static String longToIp(long l) {
    String num = Long.toBinaryString(l);
    while (num.length() < 32) {
      num = "0" + num;
    }
    String[] ans = new String[4];
    for (int i = 0; i < 4; i++) {
      String s = num.substring(i * 8, i * 8 + 8);
      //转换为10进制字符串
      s = Integer.toString(Integer.parseInt(s, 2));
      ans[i] = s;
    }
    return String.join(".", ans);
  }

  private static Long ipToLong(String str) {
    String[] split = str.split("\\.");
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < split.length; i++) {
      int i1 = Integer.parseInt(split[i]);
      String string = Integer.toBinaryString(i1);
      while (string.length() < 8) {
        string = "0" + string;
      }
      sb.append(string);
    }
    //流转换位字符串，然后将二进制转换位long
    return Long.parseLong(sb.toString(), 2);
  }

}
